package com.sali.b_design_pattern.i_iterator_pattern;


import com.sali.b_design_pattern.i_iterator_pattern.pojo.Student;
import com.sali.b_design_pattern.i_iterator_pattern.service.impl.ConcreteStudentCollection;

public class Main {

    public static void main(String[] args) {
        // 创建具体可迭代对象
        ConcreteStudentCollection studentCollection = new ConcreteStudentCollection();
        // 读取学⽣信息并添加到集合
        for (int i = 0; i < 3; i++) {
            Student student = new Student("sali-" + i, "id-" + i);
            studentCollection.addStudent(student);
        }
        // 使⽤迭代器遍历学⽣集合
        java.util.Iterator<Student> iterator = studentCollection.iterator();
        while (iterator.hasNext()) {
            Student student = iterator.next();
            System.out.println(student.getName() + " " + student.getStudentId());
        }
    }
}
